package main

import (
	"Family/app/controller"
	"Family/app/entity"
	"Family/library"
	"Family/library/log"
	"Family/route"
)

func main() {
	log.Info("application run")
	library.DbCon()
	migration()
}

// 进行数据迁移
func migration() {
	var count int64
	library.Db.Count(&count).First(entity.Member{})
	if count == 0 {
		var mode []entity.Member
		data1 := entity.Member{
			Nickname:   "蒋介石",
			Gender:     1,
			Birthdate:  "2022-05-30",
			Intro:      "xxx",
			MateId:     2,
			FatherId:   0,
			MotherId:   0,
			CreateTime: controller.ThisTime(),
		}

		data2 := entity.Member{
			Nickname:   "宋美龄",
			Gender:     0,
			Birthdate:  "2022-05-30",
			Intro:      "xxx",
			MateId:     1,
			FatherId:   0,
			MotherId:   0,
			CreateTime: controller.ThisTime(),
		}
		mode = append(mode, data1, data2)

		library.Db.Create(&mode)
	}
	library.Db.AutoMigrate(entity.Member{})
}
